package com.woniu.dao;

import com.woniu.dto.MyActivityPost;
import com.woniu.pojo.ActivityUser;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface ActivityUserMapper {

    int deleteByPrimaryKey(Integer id);

    int insert(ActivityUser record);

    int insertSelective(ActivityUser record);

    ActivityUser selectByPrimaryKey(Integer id);

    int updateByPrimaryKeySelective(ActivityUser record);

    int updateByPrimaryKey(ActivityUser record);

    @Select(value = "select * from community_activity_user where cau_activity_id = #{activityId} and cau_user_id = #{userId}")
    ActivityUser selectByIdAndUserId(Integer activityId, Integer userId);

    @Delete(value = "delete from community_activity_user where cau_activity_id = #{activityId} and cau_user_id = #{userId}")
    int deleteById(Integer activityId, Integer userId);

    @Select(value = "select name from person_user where id = #{userId}")
    String selectNameById(Integer userId);

    @Select(value = "select cau.*,pu.name from community_activity_user cau,person_user pu where cau.cau_activity_id = #{activityId} and cau.cau_user_id = pu.id and cau.cau_sign_status<3 order by cau.cau_sign_status asc")
    List<MyActivityPost> selectByActivityId(Integer activityId);
}